package fregat.connector.base;

import java.io.File;

/**
 * Stores directory and name of a full file path for easier access.
 */
public class FileDescription {

  private String directory;
  private String name;
  private boolean transferred = true;

  /**
   * Creates a file description by separating directory and name from
   * the given file path by using the system's path separator
   *
   * @param path Full file path (eg. /u/lms/sst or c:\sst
   */
  public FileDescription(String path) {
    int pos = path.lastIndexOf(File.separator) + 1;
    if (pos > 0) {
      name = path.substring(pos, path.length());
      directory = path.substring(0, pos);
    } else {
      name = path;
      directory = "";
    }
  }

  public String toString() {
    return directory + name;
  }

  public String getName() {
    return name;
  }

  public String getDirectory() {
    return directory;
  }

  public boolean wasTransferred() {
    return transferred;
  }

  public void setTransferred(boolean transferred) {
    this.transferred = transferred;
  }
}
